'use strict';
exports = module.exports = function ($scope, $rootScope, $timeout, $alert, $state, $notify, $go, $API, throttleSubmit, $rule) {
    $scope.Rule = $rule;
    $scope.frm = {
        // 表单项: 用户名
        username: '',
        // 表单项: 账号
        account: '',
        // 表单项: 中奖概率
        rote: '',
        // 表单项: 花费金钱
        lotteryDate: '',
        // 表单项: 中奖日期
    }
    $notify.clear()
    window.fromCacheObj = window.fromCacheObj || {};
    window.fromCacheObj['makeform7'] = window.fromCacheObj['makeform7'] || []
    var l = window.fromCacheObj['makeform7'].length
    window.fromCacheObj['makeform7'].push($scope.frm)
    if( l > 0 ){
        $notify.oprate("2019年6月21日18:45:34<br>您有一个表单未提交", function(close){
            console.log('ok')
            $timeout(function(){
                angular.extend($scope.frm, window.fromCacheObj['makeform7'][l-1])
                console.log(window.fromCacheObj)
                close()
            }, 1)
        })
    }
    var id = 12; // 获取到传参 比如$stateparam
    $API.Detail.cardfrom({id:id})
    .then(function(data) {
        $timeout(function() {
            angular.extend($scope.frm, data)
        }, 1)
    });
    $scope.frm2 = {
    }
    $scope.submitFun = throttleSubmit(function(){
        $scope.From.submitted = true;
        if( $scope.From.$invalid ) {
            $alert.error('请检查提交的信息')
            return false;
        }
        return $scope.frm
    },function(enable, param){
        console.log('提交代码', param)
        $timeout(function(){
            enable()
            window.fromCacheObj['makeform7'] = []
        },3e3)
    });
    $scope.cancelFun = function(){
        $alert.confirm("是否取消编辑？", function(close){
            $go('-1');
            close();
            window.fromCacheObj['makeform7'] = []
        })
    };
}